<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>杨义权的博客</title>
    <meta name="viewport" content="width=device-width, initial-scale=1">
    {{ template "common/link.html" }}
</head>
<body class="lay-blog">
{{ template "common/head.html" . }}
<div class="container-wrap">
    <div class="container">
        <div class="contar-wrap">
            <form class="layui-form" action="">
                <div class="layui-form-item">
                    <label class="layui-form-label">标题：</label>
                    <div class="layui-input-block">
                        <input  name="title"  type="text" class="layui-input" placeholder="请输入标题" value="{{ .node.Title }}">
                    </div>
                </div>
                <div class="layui-form-item">
                    <div id="editor">
                        <p>{{ str2html .node.Content }}</p>
                    </div>
                </div>
                <div class="layui-form-item">
                    <div class="layui-input-block">
                        <button class="layui-btn text-center" lay-submit lay-filter="send">发表文章</button>
                    </div>
                </div>
            </form>
        </div>
    </div>
</div>
{{ template "common/footer.html" . }}
<script src="/static/layui/layui.js"></script>
<script src="https://cdn.jsdelivr.net/npm/wangeditor@latest/dist/wangEditor.min.js"></script>
<script type="text/javascript">
    var E = window.wangEditor
    var editor = new E('#editor')
    editor.create()
</script>
<script language="JavaScript">
    layui.use(['form','jquery'], function(){
        var form = layui.form,
            $=layui.$;
        form.render();
        //监听提交
        form.on('submit(send)', function(rdata){
            rdata.field.content=editor.txt.html();
            $.post("/node/save/{{ .node.Uuid }}",rdata.field,function (data){
                if (data.code===0){
                    layer.msg("修改成功");
                    if(data.action){
                        setTimeout(function (){
                            window.location.href=data.action
                        },300)
                    }
                }else {
                    layer.msg("修改失败");
                }
            },"json").error(function (){
                layer.msg("网络异常");
            })
            return false;
        })
    })
</script>
</body>
</html>